package com.zhentao.controller;

import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.pojo.market.ChargeCoupon;
import com.zhentao.model.pojo.market.ChargeCouponParam;
import com.zhentao.service.ChargeCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName: ChargeCouponController
 * @Author: 振涛教育_Q
 * @Date: 2024/12/26 14:07
 */
@RestController
@RequestMapping("/market/api")
public class ChargeCouponController {

    @Autowired
    private ChargeCouponService couponService;


    /**
     * @description  查询待领取的优惠卷列表
     * @author 振涛教育_小Q
     * @date    2024/12/26 14:02
     * @param param
     * @return com.zhentao.model.common.dtos.ResponseResult
     */
    @PostMapping("/coupon/page")
    public ResponseResult chargeCouponList(@RequestBody ChargeCouponParam param){

        return couponService.chargeCouponList(param);
    }

    /**
     * @description  点击领取优惠卷
     * @author 振涛教育_小Q
     * @date    2024/12/26 15:39
      * @param coupon
     * @return com.zhentao.model.common.dtos.ResponseResult
     */
    @PostMapping("/user/coupon/add")
    public ResponseResult addUserCoupon(@RequestBody ChargeCoupon coupon){
        return couponService.addUserCoupon(coupon);
    }

    /*
        处理已经使用过的优惠券
     */
    @PostMapping("/user/coupon/status")
    public ResponseResult updateByIdCouponStatus(@RequestBody List<Integer> couponIds){
        return couponService.updateBatchByIdCouponStatus(couponIds);
    }
}
